package lanqiao.hol.control;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.lanqiao.tjut.bean.TBStudentBean;
import org.lanqiao.tjut.model.ModelFactory;
import org.lanqiao.tjut.myUtils.MyUtils;

import com.alibaba.fastjson.JSON;

/**
 * 学生信息查询 StudentInfoAjaxQueryServlet
 */
@WebServlet("/StudentInfoAjaxQueryServlet")
public class StudentInfoAjaxQueryServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// 获取查询表单的实体类参数
		TBStudentBean stuB = MyUtils.convertRequest2Bean(request, TBStudentBean.class, null, null);
		// 调用model层进行数据查询
		List<TBStudentBean> lstStus = ModelFactory.getStudentModelInstance().queryStudentInfoByParas(stuB);
		//发回相应内容之前，需要将返回的java的数据结果对象转换为json对象
		//将查询结果集转换为json对象
		String json = JSON.toJSONStringWithDateFormat(lstStus, "yyyy-MM-dd HH:mm:ss");
		// 使用writer对象将服务器响应内容写到客户端
		PrintWriter pw = response.getWriter();
		pw.write(json);
		pw.flush();
		pw.close();

	}

}
